<%@ page language="java"  contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<html>
<head>
<title>选择组织/单位</title>
<%@ include file="/commons/meta.jsp" %>
<%@ include file="/commons/header.jsp" %>
<%@ include file="/extjs/jsps/importExt.jsp" %>
<%@ include file="/extjs/jsps/importEasyExt.jsp" %>
<script language="javascript" type="text/javascript">
function closeCurrentWindow() {
	var winId='${winId}';
	var closeWin=Ext.WindowMgr.get(winId);
	if(closeWin==null){
		closeWin=parent.Ext.WindowMgr.get(winId);
	}
	if(closeWin==null){
		window.returnValue=false;
		window.close();
	}else{
		closeWin.returnValue=false;
		closeWin.close();
	}
}
function chooseTreeNode(node) {
	var obj;
	var winId='${winId}';
	var closeWin=Ext.WindowMgr.get(winId);
	if(closeWin==null){
		closeWin=parent.Ext.WindowMgr.get(winId);
	}
	if(closeWin==null){
		obj=window.dialogArguments;
	}else{
		obj=new Object();
	}
	obj.id=node.id;
	obj.name=node.text;
	if(closeWin==null){
		window.returnValue=true;
		window.close();
	}else{
		closeWin.returnValue=obj;
		closeWin.close();
	}
}

var treepanel = new Ext.tree.TreePanel({
	style: 'text-align: left',
	autoScroll: true, // 自动滚动 
	frame: false, // 美化界面 
	enableDD: false,// 是否支持拖拽效果 
	containerScroll: true,// 是否支持滚动条 
	rootVisible: true, // 是否隐藏根节点,很多情况下，我们选择隐藏根节点增加美观性 
	border: true, // 边框
	animate: true, // 动画效果
	singleExpand: true,
    root: new Ext.tree.AsyncTreeNode({
		id: '1',
		text: '${ROOT_NAME}',
		leaf: false,
		expanded: true,
		singleClickExpand: true
    }),
	loader: new Ext.tree.TreeLoader({
		baseAttrs: {
			singleClickExpand: true
		},
		url: '${ctx}/org!listJSON.action'
	}),
	listeners: {
		dblclick: function(node,e) {
			chooseTreeNode(node);
		}
	},
	bbar: [{
		text: '取消',
		iconCls: 'delete2Btn',
		handler: function() {
			closeCurrentWindow();
		}
	},'-']
});

Ext.onReady(function() {
	var viewport = new Ext.Viewport({
		layout: 'fit',
		items: [treepanel]
	});
});
</script>
</head>

<body>
</body>
</html>
